(function($) {
	
$.fn.dropdown = function(options) {
	
	var settings = $.extend({
		animate: true,
		duration: 100
	},options);

	var htm = $('html');
		
	return this.each(function() {
		var sel = $(this),
			dd = $('<div class="f-dropdown"/>'),
			tf = $('<input readonly="readonly"/>'),
			btn = $('<div class="f-dropdown-btn"></div>'),
			list = $('<div class="f-dropdown-list"/>'),
			options = sel.find('option');
		for (var i = 0, maxi = 	options.length; i < maxi; i++) {
			var opt = $(options[i]),
				item = $('<div class="f-dropdown-option"/>')
					.data('fValue',opt.attr('value')).html(opt.html());
			list.append(item);
		}
		tf.val(sel.find('option:selected').val()).blur(function() {
			list.slideUp('fast');
		});	
		list.find('.f-dropdown-option').click(function() {
			var opt = $(this);
			tf.val(opt.text());
			sel.val(opt.data('fValue'));
		});
		btn.click(function() {
			list.slideToggle('fast');
			tf.focus();
		});
		dd.append(btn,tf,list.hide());
		sel.hide().after(dd);
	});

};

})(jQuery);
